package com.cocola.controller;

import com.cocola.service.DateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import static com.cocola.controller.UserController.USERNAME;

@Controller
@CrossOrigin
public class DateController {

    @Autowired
    private DateService dateService;

    @RequestMapping("toDate")
    public String toDate(Model model) {
        if(USERNAME != null) {
            return "apply7";

        } else {
            model.addAttribute("error", "请登陆");
            return "login_person";
        }
    }

    @RequestMapping("/doDate")
    public String doDate(String idPhoto, String postdoctoralPhoto, String certificatePhoto, String laborcontractPhoto) {
        try {
            dateService.add(idPhoto, postdoctoralPhoto, certificatePhoto, laborcontractPhoto);
            System.out.println("addDate done ==================================>");
            return "main";

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "main";
    }
}
